package myLock;

import java.util.ArrayList;
import java.util.List;

public class Main {
    private static int count = 100000;
    public static void main(String[] args) throws InterruptedException {
        // 创建两个线程，对一个数进行操作
        MyLock lock = new MyLock();
        List<Thread> threads = new ArrayList<Thread>();
        for (int i = 0; i < 10000; i ++) {
            threads.add(new Thread(() -> {
                for (int j = 0; j < 10000; j ++) {
                    lock.lock();
                    count --;
                }
                for (int j = 0; j < 10000; j ++) {
                    lock.unlock();
                }
            }));
        }
        for (Thread thread : threads) {
            thread.start();
        }

        for (Thread thread : threads) {
            thread.join();
        }
        System.out.println(count);
    }
}
